home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / include / sys / wait.h < prev   
C/C++ Source or Header  |  1991-07-25  |  3KB  |  91 lines

  1. /*
  2.  * Copyright (c) 1982, 1986 Regents of the University of California.
  3.  * All rights reserved.  The Berkeley software License Agreement
  4.  * specifies the terms and conditions for redistribution.
  5.  *
  6.  *    @(#)wait.h    7.4 (Berkeley) 1/27/88
  7.  */
  8.  
  9. #ifndef _WAIT
  10. #define _WAIT
  11.  
  12. /*
  13.  * This file holds definitions relevent to the wait system call.
  14.  * Some of the options here are available only through the ``wait3''
  15.  * entry point; the old entry point with one argument has more fixed
  16.  * semantics, never returning status of unstopped children, hanging until
  17.  * a process terminates if any are outstanding, and never returns
  18.  * detailed information about process resource utilization (<vtimes.h>).
  19.  */
  20.  
  21. #include <machine/machparam.h>
  22.  
  23. /*
  24.  * Structure of the information in the first word returned by both
  25.  * wait and wait3.  If w_stopval==WSTOPPED, then the second structure
  26.  * describes the information returned, else the first.  See WUNTRACED below.
  27.  */
  28. union wait    {
  29.     int    w_status;        /* used in syscall */
  30.     /*
  31.      * Terminated process status.
  32.      */
  33.     struct {
  34. #if BYTE_ORDER == LITTLE_ENDIAN
  35.         unsigned int    w_Termsig:7;    /* termination signal */
  36.         unsigned int    w_Coredump:1;    /* core dump indicator */
  37.         unsigned int    w_Retcode:8;    /* exit code if w_termsig==0 */
  38. #endif
  39. #if BYTE_ORDER == BIG_ENDIAN
  40.         unsigned short    w_Filler;    /* upper bits filler */
  41.         unsigned char    w_Retcode;    /* exit code if w_termsig==0 */
  42.         unsigned int    w_Coredump:1;    /* core dump indicator */
  43.         unsigned int    w_Termsig:7;    /* termination signal */
  44. #endif
  45.     } w_T;
  46.     /*
  47.      * Stopped process status.  Returned
  48.      * only for traced children unless requested
  49.      * with the WUNTRACED option bit.
  50.      */
  51.     struct {
  52. #if BYTE_ORDER == LITTLE_ENDIAN
  53.         unsigned int    w_Stopval:8;    /* == W_STOPPED if stopped */
  54.         unsigned int    w_Stopsig:8;    /* signal that stopped us */
  55. #else
  56.         unsigned short    w_Filler;    /* upper bits filler */
  57.         unsigned char    w_Stopsig;    /* signal that stopped us */
  58.         unsigned char    w_Stopval;    /* == W_STOPPED if stopped */
  59. #endif
  60.     } w_S;
  61. };
  62. #define    w_termsig    w_T.w_Termsig
  63. #define w_coredump    w_T.w_Coredump
  64. #define w_retcode    w_T.w_Retcode
  65. #define w_stopval    w_S.w_Stopval
  66. #define w_stopsig    w_S.w_Stopsig
  67.  
  68.  
  69. #define    WSTOPPED    0177    /* value of s.stopval if process is stopped */
  70.  
  71. /*
  72.  * Option bits for the second argument of wait3.  WNOHANG causes the
  73.  * wait to not hang if there are no stopped or terminated processes, rather
  74.  * returning an error indication in this case (pid==0).  WUNTRACED
  75.  * indicates that the caller should receive status about untraced children
  76.  * which stop due to signals.  If children are stopped and a wait without
  77.  * this option is done, it is as though they were still running... nothing
  78.  * about them is returned.
  79.  */
  80. #define WNOHANG        1    /* dont hang in wait */
  81. #define WUNTRACED    2    /* tell about stopped, untraced children */
  82.  
  83. #define WIFSTOPPED(x)    ((x).w_stopval == WSTOPPED)
  84. #define WIFSIGNALED(x)    ((x).w_stopval != WSTOPPED && (x).w_termsig != 0)
  85. #define WIFEXITED(x)    ((x).w_stopval != WSTOPPED && (x).w_termsig == 0)
  86.  
  87. extern int wait();
  88. extern int wait3();
  89.  
  90. #endif /* _WAIT */
  91.